<?php
	session_start();
	if(isset($_SESSION['pos']))
	{
		if($_SESSION['pos'] == "Manager")
		{
			header("Location: managerpage.php");
		}
		else
		{
			header("Location: employeepage.php");
		}
	}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>APO Cooperative Database System - Create Account</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8rc2.custom.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8rc2.custom.min.js"></script>
<script type="text/javascript">
$(window).load(function()
{
	$(".tin_error").hide();
	$(".empno_error").hide();
	$(".pass_error").hide();
	$(".fname_error").hide();
	$(".mname_error").hide();
	$(".lname_error").hide();
});
$(document).ready(function()
{
	$("#datepicker").datepicker({ changeYear: true, dateFormat: 'yy-mm-dd' });
	$("#back").click(function()
	{
		window.location="index.php"
	});
	$("#tin").blur(function()
	{
		if($("#tin").attr("value").length < 12)
		{
			$(".tin_error").show();
		}
		else
			$(".tin_error").hide();
	});
	$("#employeeNumber").blur(function()
	{
		if($("#employeeNumber").attr("value").length < 10)
		{
			$(".empno_error").show();
		}
		else
			$(".empno_error").hide();
	});
	$("#password").blur(function()
	{
		if($("#password").attr("value").length < 6)
		{
			$(".pass_error").show();
		}
		else
			$(".pass_error").hide();
	});
	$("#firstName").blur(function()
	{
		if($("#firstName").attr("value").length < 2)
		{
			$(".fname_error").show();
		}
		else
			$(".fname_error").hide();
	});
	$("#middleName").blur(function()
	{
		if($("#middleName").attr("value").length < 2)
		{
			$(".mname_error").show();
		}
		else
			$(".mname_error").hide();
	});
	$("#lastName").blur(function()
	{
		if($("#lastName").attr("value").length < 2)
		{
			$(".lname_error").show();
		}
		else
			$(".lname_error").hide();
	});
});
</script>
</head>
<body>
<div class="container ui-corner-all ">
	<div class="header ui-corner-top">
  <h1>APO Cooperative Database System</h1>
</div>
<div class="divider"></div>
  <div class="wrapper">
    <div class="content">
      <?php
			if (isset($_SESSION['stat'],$_SESSION['msg']))
			{
				if($_SESSION['stat'] == "create_error")
				{
					echo "<div class=\"ui-state-error\" style=\"width: 90%\">".$_SESSION['msg']."</div>";
				}
				unset($_SESSION['stat'], $_SESSION['msg']);
			}
		?>
      <p style="font-weight:bold">Please fill up the form</p>
      <p>
      <table>
      <form action="accountController.php" method="post">
	  <tr>
        <td>Employee Number:</td>
        <td><input type="text" name="employeeNumber" id="employeeNumber" /><span class="empno_error ui-state-error">Invalid Employee Number</span></td> 
      </tr>
      <tr>
        <td>Password: </td>
        <td><input type="password" name="password" id="password" /><span class="pass_error ui-state-error">Password too short</span></td>
      </tr>
      <tr>
        <td>First Name: </td>
        <td><input type="text" name="firstName" id="firstName" /><span class="fname_error ui-state-error">Please enter your first name</span></td>
      </tr>
      <tr>
        <td>Middle Name: </td>
        <td><input type="text" name="middleName" id="middleName" /><span class="mname_error ui-state-error">Please enter your middle name</span></td>
      </tr>
      <tr>
        <td>Last Name: </td>
        <td><input type="text" name="lastName" id="lastName" /><span class="lname_error ui-state-error">Please enter your last name</span></td>
      </tr>
      <tr>
        <td>TIN: </td>
        <td><input type="text" name="tin" id="tin"/><span class="tin_error ui-state-error">Invalid TIN</span></td>
      </tr>
      <tr>
        <td>Position: </td>
        <td>
            <select name="position">
				<option value="Manager">Manager</option>            
                <option value="Regular">Regular Employee</option>
            </select>
        </td>
      </tr>
      <tr>
      	<td>Branch: </td>
        <td><input type="text" name="branch" /></td>
      </tr>
      <tr>
      	<td>Branch Address: </td>
        <td><input type="text" name="branchAddress" /></td>
      </tr>
      <tr>
      	<td>Contact Number: </td>
        <td><input type="text" name="contactNumber" /></td>
      </tr>
      <tr>
      	<td>Birthday: </td>
        <td><input type="text" name="birthday" id="datepicker" readonly="readonly" /></td>
      </tr>
      </table>
        
        <input type="submit"  />
        <input type="button" value="Back" id="back"  />
        <input type="reset" />
        </form>
        
      </p>
    </div></div>
  <div class="login ui-corner-all">
    <div class="navheader ui-corner-top"></div>
  	<div class="userstat">
    <?php
			echo 
			"<form action=\"logInController.php\" method=\"post\">
			Username: <br />
			<input type=\"text\" name=\"username\" /><br />
			Password:<br />
			<input type=\"password\" name=\"password\"  /><br />
			<br />
			<input type=\"submit\"  />
			</form>	
			<a href=\"createAccountView.php\">Register</a>";
	?>
    </div>
    </div>
    <div class="footer ui-corner-bottom">
    <a href="#">Contact Us</a> | <a href="#">Terms of Use</a> | <a href="#">Trademarks</a> | <a href="#">Privacy Statement</a><br />
    Copyright &copy; 2009 . All Rights Reserved.
  </div>
</div>
</body>
</html>
